package org.community.controller;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.community.service.detail.DetailService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/community/personal/picture")
//@RequiredArgsConstructor
@Data
@Slf4j
public class PortraitController {

    @Resource
    private DetailService detailService;


    //上传头像的方法
    @PostMapping(
            value = "/portrait/{userId}",
            consumes = MediaType.MULTIPART_FORM_DATA_VALUE
    )
    public Object uploadPortrait(@PathVariable("userId")Integer userId, MultipartFile file){
        log.info("uploadPortrait开始执行");

        return this.getDetailService().portraitUpload(userId,file);
    }
}
